package com.yc.bbs.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yc.bbs.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.bbs.entity.UserEx;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * BBS论坛-用户表-6 Mapper 接口
 * </p>
 *
 * @author ly
 * @since 2024-11-23
 */
public interface UserMapper extends BaseMapper<User> {
@Update("update tbl_user set upass = #{user.upass} where uname=#{user.uname}")
    int updP(@Param("user") User user);

    @Select("SELECT * FROM tbl_user")
    List<User> selectUsers();

    @Select("<script>" +
            "SELECT * FROM tbl_user " +
            "<where>" +
            "<if test='uname != null and uname != \"\"'>AND uname = #{uname}</if>" +
            "<if test='email != null and email != \"\"'>AND email = #{email}</if>" +
            "<if test='status != null and status != 0'>AND status = #{status}</if>" +
            "</where>" +
            "</script>")
    List<User> findMemberByQuery(@Param("uname") String uname, @Param("email") String email, @Param("status") Integer status);

    @Select("select * from tbl_user where uname = #{uname}")
    User findByNa(@Param("uname") String uname);


}
